<?php

/**
 * Show Product Link Element for backend area
 */
class AW_Imagetest_Model_Form_Element_Product extends Varien_Data_Form_Element_Text
{
    /**
     * Retrives element html
     * @return string
     */
    public function getElementHtml()
    {
        $product_id = Mage::app()->getRequest()->getParam('product_id');
        if ($product_id){
            $product = Mage::getModel('catalog/product')->load($product_id);
            $productUrl = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => $product_id));
            $selectorUrl = Mage::helper('adminhtml')->getUrl('imagetest_admin/admin_image/new');            
//            $html = "<a href=\"{$productUrl}\">".$product->getName()."</a>";
            $html = $product->getName();
            $html .= " ["."<a href=\"{$productUrl}\">".Mage::helper('imagetest')->__('view')."</a>"."]";
            $html .= " ["."<a href=\"{$selectorUrl}\">".Mage::helper('imagetest')->__('change')."</a>"."]";
            $html .= "<input type=\"hidden\" value=\"{$product_id}\" name=\"product_id\" id=\"product_id\">";
            return $html;
        }
        return '';
    }
}

